package com.fagejiang.gateway.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * TODO
 *
 * @author 发哥讲Java
 * @version 1.0
 * @date 2021-05-17 13:37
 */
@Component
@Slf4j
public class CustomGlobalFilter2 implements GlobalFilter , Ordered {

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("进入到 global filter  2222222222" + exchange);
        System.out.println("进入到 global filter  2222222222" + chain);
        // 调用 chain.filter(exchange) 通过此 过滤器,
        // return java.lang.NullPointerException: The Mono returned by the supplier is null ,异常返回
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 2;
    }
}
